<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>函数接收参数并弹出</title>
    <style>
        body{font:12px/1.5 Tahoma;text-align:center;}
        code,input,button{font-family:inherit;}
        input{border:1px solid #ccc;padding:3px;}
        button{cursor:pointer;}
    </style>

</head>
<body>
<p><input type="text" value="北京市" /></p>
<p><input type="text" value="朝阳区" /></p>
<p><button>传参</button></p>

<script>
    var myFn = function (a,b){
        alert(a.value);
        alert(b.value);
    };
    window.onload = function (){
        var oInput = document.getElementsByTagName('input');
        var oBtn = document.getElementsByTagName('button')[0];
        oBtn.onclick = function (){
            myFn(oInput[0],oInput[1]);
        }
    }
</script>
</body>
</html>
